'use strict';
/*
 * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
 * This devtool is neither made for production nor for readable output files.
 * It uses "eval()" calls to create a separate source file in the browser devtools.
 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
 * or disable the default devtool with "devtool: false".
 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
 */
( self.webpackChunkast_block_templates = self.webpackChunkast_block_templates || [] ).push( [ [ 'src_components_reusable_single-block_lazy-single-block-new_js' ], {

	/***/ './src/components/reusable/import-block-button/import-block-button-new.js':
	/*!********************************************************************************!*\
  !*** ./src/components/reusable/import-block-button/import-block-button-new.js ***!
  \********************************************************************************/
	/***/ ( function( __unused_webpack_module, __webpack_exports__, __webpack_require__ ) {
		eval( "__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @wordpress/data */ \"./node_modules/@wordpress/data/build-module/components/use-select/index.js\");\n/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @wordpress/data */ \"./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch.js\");\n/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! @wordpress/data */ \"./node_modules/@wordpress/data/build-module/components/with-select/index.js\");\n/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! @wordpress/data */ \"./node_modules/@wordpress/data/build-module/components/with-dispatch/index.js\");\n/* harmony import */ var _wordpress_compose__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! @wordpress/compose */ \"./node_modules/@wordpress/compose/build-module/higher-order/compose.js\");\n/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @wordpress/element */ \"react\");\n/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_10__);\n/* harmony import */ var _button_button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../button/button */ \"./src/components/reusable/button/button.js\");\n/* harmony import */ var _loading_spinner_loading_spinner__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../loading-spinner/loading-spinner */ \"./src/components/reusable/loading-spinner/loading-spinner.js\");\n/* harmony import */ var _utils_plugins__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../utils/plugins */ \"./src/utils/plugins.js\");\n/* harmony import */ var _utils_serialize__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../utils/serialize */ \"./src/utils/serialize.js\");\n/* harmony import */ var _utils_rest_api__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../utils/rest-api */ \"./src/utils/rest-api.js\");\n/* harmony import */ var _utils_functions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../utils/functions */ \"./src/utils/functions.js\");\n/* harmony import */ var _heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @heroicons/react/24/outline */ \"./node_modules/@heroicons/react/24/outline/esm/PlusIcon.js\");\n/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../utils/helpers */ \"./src/utils/helpers.js\");\n/* harmony import */ var react_toastify__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react-toastify */ \"./node_modules/react-toastify/dist/react-toastify.esm.mjs\");\n/* harmony import */ var _toaster__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../toaster */ \"./src/components/reusable/toaster/index.js\");\n/* harmony import */ var _store_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../store/index */ \"./src/store/index.js\");\nconst {\n  post\n} = wp.ajax;\nconst {\n  parse\n} = wp.blocks;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst ImportBlockButton = _ref => {\n  let {\n    setImportItemInfo,\n    requiredPlugins,\n    importItemInfo,\n    title,\n    btnClass,\n    insertBlocks,\n    onSetTogglePopup,\n    item,\n    onClick,\n    onBlockImport,\n    activePaletteSlug,\n    disableAI,\n    importing = false\n  } = _ref;\n  let [blockInfo] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_10__.useState)(importItemInfo);\n  let AllRequiredPlugins = requiredPlugins ? requiredPlugins : [];\n  const buttonClass = btnClass ? btnClass : '';\n  const [buttonTitle] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_10__.useState)(title ? title : 'Import');\n  const {\n    insertIndex\n  } = wp.data.select('core/block-editor').getBlockInsertionPoint();\n  const {\n    importInProgress\n  } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_11__[\"default\"])(select => {\n    const {\n      getImportInProgress\n    } = select(_store_index__WEBPACK_IMPORTED_MODULE_9__.STORE_KEY);\n    return {\n      importInProgress: getImportInProgress()\n    };\n  }, []);\n  const {\n    setImportInProgress\n  } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_12__[\"default\"])(_store_index__WEBPACK_IMPORTED_MODULE_9__.STORE_KEY);\n  const importNotice = (noticeTitle, noticeMessage, noticeType) => {\n    (0,react_toastify__WEBPACK_IMPORTED_MODULE_7__.toast)((0,_toaster__WEBPACK_IMPORTED_MODULE_8__[\"default\"])({\n      title: noticeTitle,\n      message: noticeMessage\n    }), _toaster__WEBPACK_IMPORTED_MODULE_8__[\"default\"].getOptions({\n      type: noticeType\n    }));\n  };\n  const install_spectra = () => {\n    (0,_utils_plugins__WEBPACK_IMPORTED_MODULE_2__.install_plugin)({\n      slug: 'ultimate-addons-for-gutenberg',\n      init: 'ultimate-addons-for-gutenberg/ultimate-addons-for-gutenberg.php',\n      name: 'Spectra'\n    }).then(() => {\n      activate_spectra();\n    }).catch(() => {\n      setImportInProgress(false);\n      importNotice('Import failed!', 'Spectra installation failed!', 'error');\n    });\n  };\n  const activate_spectra = () => {\n    (0,_utils_plugins__WEBPACK_IMPORTED_MODULE_2__.activate_plugin)({\n      slug: 'ultimate-addons-for-gutenberg',\n      init: 'ultimate-addons-for-gutenberg/ultimate-addons-for-gutenberg.php',\n      name: 'Spectra'\n    }).then(() => {}).catch(() => {\n      setImportInProgress(false);\n      importNotice('Import failed!', 'Spectra activation failed!', 'error');\n    });\n  };\n  const install_wpforms = () => {\n    (0,_utils_plugins__WEBPACK_IMPORTED_MODULE_2__.install_plugin)({\n      slug: 'wpforms-lite',\n      init: 'wpforms-lite/wpforms.php',\n      name: 'WPForms Lite'\n    }).then(() => {\n      activate_wpforms();\n    }).catch(() => {\n      setImportInProgress(false);\n      importNotice('Import failed!', 'WPForms installation failed!', 'error');\n    });\n  };\n  const activate_wpforms = () => {\n    (0,_utils_plugins__WEBPACK_IMPORTED_MODULE_2__.activate_plugin)({\n      slug: 'wpforms-lite',\n      init: 'wpforms-lite/wpforms.php',\n      name: 'WPForms Lite'\n    }).then(() => {\n      start_import_process();\n    }).catch(() => {\n      setImportInProgress(false);\n      importNotice('Import failed!', 'WPForms activation failed!', 'error');\n    });\n  };\n  const import_wpforms = wpforms_url => {\n    post({\n      action: 'ast_block_templates_import_wpforms',\n      id: blockInfo.id,\n      _ajax_nonce: ast_block_template_vars._ajax_nonce\n    }).done(() => {\n      // Import block.\n      import_block();\n    }).fail(() => {\n      setImportInProgress(false);\n      importNotice('Import failed!', 'WPForms import failed!', 'error');\n    });\n  };\n  const import_block = () => {\n    const content = blockInfo.original_content;\n    const category = blockInfo['blocks-category'][0];\n    post({\n      action: 'ast_block_templates_import_block',\n      content,\n      category,\n      _ajax_nonce: ast_block_template_vars._ajax_nonce,\n      style: activePaletteSlug,\n      disableAI\n    }).done(content => {\n      setImportInProgress(false);\n\n      // Manipulate attribute block id.\n      const manipulatedBlocks = (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_6__.manipulateAttributeBlockId)(parse(content));\n      insertBlocks(manipulatedBlocks, insertIndex, '', false);\n      onSetTogglePopup();\n      document.getElementById('ast-block-templates-modal-wrap').classList.remove('open');\n      document.body.classList.remove('ast-block-templates-modal-open');\n\n      // On block import callback.\n      if ('function' === typeof onBlockImport) {\n        onBlockImport(content, insertIndex);\n      }\n      if (ast_block_template_vars.spectra_status !== 'active') {\n        (0,_utils_functions__WEBPACK_IMPORTED_MODULE_5__.savePostIfSpectraInactive)();\n      }\n    }).fail(response => {\n      importNotice('Import failed!', response, 'error');\n    });\n  };\n  const start_import_process = () => {\n    // Import WP Forms.\n    // 1. import wp forms\n    // 2. import block\n\n    const wpforms_url = blockInfo?.['post-meta']?.['astra-site-wpforms-path'] || '';\n    if (wpforms_url) {\n      import_wpforms(wpforms_url);\n    } else {\n      import_block();\n    }\n  };\n  return /*#__PURE__*/React.createElement(_button_button__WEBPACK_IMPORTED_MODULE_0__[\"default\"], {\n    className: (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_6__.classNames)('min-w-[7rem] hover:shadow-small sp-text-sm', buttonClass, importInProgress ^ importing && 'opacity-50 cursor-not-allowed'),\n    type: \"button\",\n    variant: \"primary\",\n    onClick: event => {\n      if (importInProgress) {\n        return;\n      }\n      setImportInProgress(true);\n      if ('function' === typeof onClick) {\n        onClick(event);\n      }\n      if ('not-installed' === ast_block_template_vars.spectra_status) {\n        install_spectra();\n      } else if ('inactive' === ast_block_template_vars.spectra_status) {\n        activate_spectra();\n      }\n      (0,_utils_rest_api__WEBPACK_IMPORTED_MODULE_4__.block_api_request)(item.ID, 'astra-blocks').then(data => {\n        setImportItemInfo(data);\n\n        /**\n         * @todo Set state and use callback function.\n         * Avoid `blockInfo = data` and try to use `setBlockInfo(data)`\n         */\n        // setBlockInfo(data);\n        blockInfo = data;\n        AllRequiredPlugins = data?.['post-meta']?.['astra-blocks-required-plugins'] ? _utils_serialize__WEBPACK_IMPORTED_MODULE_3__.PHP.parse(data['post-meta']['astra-blocks-required-plugins']) : [];\n        if (AllRequiredPlugins.length) {\n          if ('not-installed' === ast_block_template_vars.wpforms_status) {\n            install_wpforms();\n          } else if ('inactive' === ast_block_template_vars.wpforms_status) {\n            activate_wpforms();\n          } else {\n            start_import_process();\n          }\n        } else {\n          start_import_process();\n        }\n      }).catch(err => {\n        importNotice('Import failed!', err, 'error');\n        setImportInProgress(true);\n      });\n    },\n    isSmall: true,\n    hasPrefixIcon: importing ? false : true\n  }, importing ? /*#__PURE__*/React.createElement(_loading_spinner_loading_spinner__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n    className: \"h-[1.3rem] w-[1.3rem] !shrink-0\"\n  }) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_13__[\"default\"], {\n    className: \"h-[1.3rem] w-[1.3rem] !shrink-0\"\n  }), buttonTitle));\n};\n/* harmony default export */ __webpack_exports__[\"default\"] = ((0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_14__[\"default\"])((0,_wordpress_data__WEBPACK_IMPORTED_MODULE_15__[\"default\"])(select => {\n  const {\n    getImportItemInfo,\n    getCurrentScreen,\n    getSitePreview,\n    getActivePaletteSlug,\n    getDisableAi\n  } = select('ast-block-templates');\n  return {\n    importItemInfo: getImportItemInfo(),\n    sitePreview: getSitePreview(),\n    currentScreen: getCurrentScreen(),\n    activePaletteSlug: getActivePaletteSlug(),\n    disableAI: getDisableAi()\n  };\n}), (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_16__[\"default\"])(dispatch => {\n  const {\n    setImportItemInfo,\n    setTogglePopup\n  } = dispatch('ast-block-templates');\n  const {\n    insertBlocks\n  } = wp.data.dispatch('core/block-editor');\n  return {\n    setImportItemInfo,\n    onSetTogglePopup: setTogglePopup,\n    insertBlocks\n  };\n}))((0,_wordpress_element__WEBPACK_IMPORTED_MODULE_10__.memo)(ImportBlockButton)));\n\n//# sourceURL=webpack://ast-block-templates/./src/components/reusable/import-block-button/import-block-button-new.js?" );
		/***/ } ),

	/***/ './src/components/reusable/single-block/favorite-single-block.js':
	/*!***********************************************************************!*\
  !*** ./src/components/reusable/single-block/favorite-single-block.js ***!
  \***********************************************************************/
	/***/ ( function( __unused_webpack_module, __webpack_exports__, __webpack_require__ ) {
		eval( "__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @heroicons/react/24/outline */ \"./node_modules/@heroicons/react/24/outline/esm/HeartIcon.js\");\n/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../utils/helpers */ \"./src/utils/helpers.js\");\n/* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/api-fetch */ \"./node_modules/@wordpress/api-fetch/build-module/index.js\");\n/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\n/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _utils_event_emitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../utils/event-emitter */ \"./src/utils/event-emitter.js\");\n/* harmony import */ var _tooltip__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../tooltip */ \"./src/components/reusable/tooltip/index.js\");\n/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @wordpress/element */ \"react\");\n/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_6__);\n/* harmony import */ var _wordpress_compose__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @wordpress/compose */ \"./node_modules/@wordpress/compose/build-module/higher-order/compose.js\");\n/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/data */ \"./node_modules/@wordpress/data/build-module/components/use-select/index.js\");\n/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @wordpress/data */ \"./node_modules/@wordpress/data/build-module/components/with-select/index.js\");\n/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @wordpress/data */ \"./node_modules/@wordpress/data/build-module/components/with-dispatch/index.js\");\nfunction _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\n\n\n\n\n\n\n\n\nconst {\n  site_url: siteUrl\n} = ast_block_template_vars;\nconst FavoriteSingleBlock = _ref => {\n  let {\n    item,\n    className,\n    setFavorites,\n    setFilterBlocksByCategory,\n    filterBlocksByCategory,\n    filterBlocksPagesByCategory,\n    setFilterBlocksPagesByCategory,\n    ...props\n  } = _ref;\n  const {\n    favorites,\n    currentScreen\n  } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_5__[\"default\"])(select => {\n    const {\n      getFavorites,\n      getCurrentScreen\n    } = select('ast-block-templates');\n    return {\n      favorites: getFavorites(),\n      currentScreen: getCurrentScreen()\n    };\n  });\n  const type = currentScreen === 'all-blocks-grid' ? 'block' : 'page';\n  const [isFavorite, setIsFavorite] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_6__.useState)(favorites[type]?.includes(+item.ID));\n  const handleClick = async event => {\n    event?.preventDefault();\n    event?.stopPropagation();\n    try {\n      await (0,_wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1__[\"default\"])({\n        path: `${siteUrl}/wp-json/gutenberg-templates/v1/favorite`,\n        data: {\n          type: item.type,\n          block_id: item.ID,\n          status: !isFavorite\n        },\n        method: 'POST',\n        headers: {\n          'X-WP-Nonce': ast_block_template_vars.rest_api_nonce,\n          'content-type': 'application/json'\n        }\n      });\n    } catch (error) {\n      // Do nothing\n      console.error(error);\n    }\n    let updatedFavorites = {\n      ...favorites\n    };\n    if (!isFavorite) {\n      updatedFavorites = {\n        ...favorites,\n        [type]: [...new Set([...favorites[type], (0,lodash__WEBPACK_IMPORTED_MODULE_2__.parseInt)(item.ID)])]\n      };\n    } else {\n      updatedFavorites = {\n        ...favorites,\n        [type]: favorites[type].filter(id => id !== (0,lodash__WEBPACK_IMPORTED_MODULE_2__.parseInt)(item.ID))\n      };\n    }\n    setIsFavorite(!isFavorite);\n    setFavorites(updatedFavorites);\n    if (!!updatedFavorites[type].length) {\n      return;\n    }\n    if (filterBlocksByCategory !== 'favorite' && filterBlocksPagesByCategory !== 'favorite') {\n      return;\n    }\n    if ('block' === type) {\n      setFilterBlocksByCategory('');\n    }\n    if ('page' === type) {\n      setFilterBlocksPagesByCategory('');\n    }\n    _utils_event_emitter__WEBPACK_IMPORTED_MODULE_3__[\"default\"].emit('reset-list-count');\n  };\n  return /*#__PURE__*/React.createElement(\"button\", _extends({\n    className: (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_0__.classNames)('flex items-center justify-center rounded-full p-2 bg-white cursor-pointer border-0 focus:outline-none', isFavorite ? '' : 'text-icon-secondary', className),\n    onClick: handleClick\n  }, props), /*#__PURE__*/React.createElement(_tooltip__WEBPACK_IMPORTED_MODULE_4__[\"default\"], {\n    content: !isFavorite && 'Add to favorites'\n  }, /*#__PURE__*/React.createElement(_heroicons_react_24_outline__WEBPACK_IMPORTED_MODULE_7__[\"default\"], {\n    className: (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_0__.classNames)('w-6 h-6 transition-colors ease-out duration-150', isFavorite ? 'fill-favorite text-favorite' : 'hover:fill-favorite hover:text-favorite')\n  })));\n};\n/* harmony default export */ __webpack_exports__[\"default\"] = ((0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_8__[\"default\"])((0,_wordpress_data__WEBPACK_IMPORTED_MODULE_9__[\"default\"])(select => {\n  const {\n    getFilterBlocksByCategory,\n    getFilterBlocksPagesByCategory\n  } = select('ast-block-templates');\n  return {\n    filterBlocksByCategory: getFilterBlocksByCategory(),\n    filterBlocksPagesByCategory: getFilterBlocksPagesByCategory()\n  };\n}), (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_10__[\"default\"])(dispatch => {\n  const {\n    setFavorites,\n    setFilterBlocksByCategory,\n    setFilterBlocksPagesByCategory\n  } = dispatch('ast-block-templates');\n  return {\n    setFavorites,\n    setFilterBlocksByCategory,\n    setFilterBlocksPagesByCategory\n  };\n}))(FavoriteSingleBlock));\n\n//# sourceURL=webpack://ast-block-templates/./src/components/reusable/single-block/favorite-single-block.js?" );
		/***/ } ),

	/***/ './src/components/reusable/single-block/lazy-single-block-new.js':
	/*!***********************************************************************!*\
  !*** ./src/components/reusable/single-block/lazy-single-block-new.js ***!
  \***********************************************************************/
	/***/ ( function( __unused_webpack_module, __webpack_exports__, __webpack_require__ ) {
		eval( "__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/element */ \"react\");\n/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../utils/helpers */ \"./src/utils/helpers.js\");\n/* harmony import */ var _import_block_button_import_block_button_new__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../import-block-button/import-block-button-new */ \"./src/components/reusable/import-block-button/import-block-button-new.js\");\n/* harmony import */ var _favorite_single_block__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./favorite-single-block */ \"./src/components/reusable/single-block/favorite-single-block.js\");\n/* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./utils.js */ \"./src/components/reusable/single-block/utils.js\");\n/* harmony import */ var _wordpress_compose__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @wordpress/compose */ \"./node_modules/@wordpress/compose/build-module/higher-order/compose.js\");\n/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @wordpress/data */ \"./node_modules/@wordpress/data/build-module/components/with-select/index.js\");\n\n\n\n\n\nconst {\n  spectra_common_styles\n} = ast_block_template_vars;\n\n\nconst visibility = {\n  hidden: 'hidden',\n  visible: 'visible'\n};\nconst SingleBlock = _ref => {\n  let {\n    item,\n    content,\n    stylesheet,\n    astraCustomizer,\n    globalStylesheet,\n    colorPalette,\n    dynamicContent,\n    selectedImages,\n    disableAi,\n    // disablePreview,\n    email,\n    phone,\n    address\n  } = _ref;\n  const thumbnailRef = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.useRef)(null);\n  const thumbnailContainerRef = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.useRef)(null);\n  const thumbnail_image_url = item['thumbnail-image-url'] || '';\n  const featured_image_url = item['featured-image-url'] || '';\n  let landscapeCounter = 0;\n  let portraitCounter = 0;\n  const [selfState, setSelfState] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.useState)({\n    importing: false\n  });\n  const [imageThumbnailURL, setThumbnailImageURL] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.useState)(`${ast_block_template_vars.uri}dist/placeholder_200_200.png`);\n  const [imageFeaturedlURL, setFeaturedImageURL] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.useState)(`${ast_block_template_vars.uri}dist/placeholder_200_200.png`);\n  const replaceImages = (images, previewImages) => {\n    if (disableAi) {\n      return;\n    }\n    const landscapeImages = previewImages.landscape ? previewImages.landscape : [];\n    const portraitImages = previewImages.portrait ? previewImages.portrait : [];\n    if (landscapeImages.length === 0 || portraitImages.length === 0) {\n      return;\n    }\n    images?.forEach(function (image) {\n      if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.shouldSkipReplacement)(image.src)) {\n        return;\n      }\n      image.onload = () => {\n        const orientation = (0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.getImageOrientation)(image.src);\n        let imageUrl;\n        if (orientation === 'landscape') {\n          imageUrl = landscapeImages[landscapeCounter];\n        } else {\n          imageUrl = portraitImages[portraitCounter];\n        }\n        if (undefined === imageUrl) {\n          updateVisibility(image, visibility.visible);\n          return;\n        }\n        if (!(imageUrl.url.includes('unsplash') || imageUrl.url.includes('pexels') || imageUrl.url.includes('pixabay'))) {\n          updateVisibility(image, visibility.visible);\n          return;\n        }\n        if (orientation === 'landscape') {\n          landscapeCounter++;\n        } else {\n          portraitCounter++;\n        }\n        if ('PICTURE' === image.parentNode.nodeName) {\n          const sourceElements = image.parentNode.querySelectorAll('source');\n          sourceElements.forEach(source => {\n            source.setAttribute('srcset', imageUrl.optimized_url);\n          });\n          const imageElement = image.parentNode.querySelector('img');\n          imageElement.setAttribute('src', imageUrl.optimized_url);\n        } else {\n          const newImage = document.createElement('img');\n          newImage.src = imageUrl.optimized_url;\n          image.parentNode.replaceChild(newImage, image);\n        }\n        updateVisibility(image, visibility.visible);\n      };\n      image.onerror = () => {\n        updateVisibility(image, visibility.visible);\n      };\n    });\n  };\n  const replaceContactDetails = contentStr => {\n    const emailSrc = 'contact@example.com';\n    const phoneSrc = '202-555-0188';\n    const addressSrc = '2360 Hood Avenue, San Diego, CA, 92123';\n    if (email) {\n      contentStr = contentStr.replace(emailSrc, email);\n    }\n    if (phone) {\n      contentStr = contentStr.replace(phoneSrc, phone);\n    }\n    if (address) {\n      contentStr = contentStr.replace(addressSrc, address);\n    }\n    return contentStr;\n  };\n  const replaceContainerImages = (styleContent, images) => {\n    if (disableAi) {\n      return styleContent;\n    }\n    if (images && images.length === 0) {\n      return styleContent;\n    }\n    const backgroundImageRegex = /background-image\\s*:\\s*url\\(['\"]?([^'\")]+)['\"]?\\)/g;\n    const newStyleContent = styleContent.replace(backgroundImageRegex, function (match, imageUrl) {\n      if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.shouldSkipReplacement)(imageUrl)) {\n        return match;\n      }\n      if (!images[landscapeCounter]?.url) {\n        return '';\n      }\n      const currentImageUrl = images[landscapeCounter]?.url;\n      landscapeCounter++;\n      return 'background-image: url(\"' + currentImageUrl + '\")';\n    });\n    return newStyleContent;\n  };\n  (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.useLayoutEffect)(() => {\n    let isMounted = true;\n    const allImages = {\n      landscape: [],\n      portrait: []\n    };\n    selectedImages?.forEach(image => {\n      if (image.orientation === 'landscape') {\n        allImages.landscape.push(image);\n      } else {\n        allImages.portrait.push(image);\n      }\n    });\n    const previewImages = allImages;\n    const imgThumbnail = new Image();\n    imgThumbnail.src = thumbnail_image_url;\n    const imgFeatured = new Image();\n    imgFeatured.src = featured_image_url;\n    const thumbnailContainer = thumbnailContainerRef.current;\n    function handleThumbnailLoad(image, setURL) {\n      if (isMounted) {\n        image.onload = () => {\n          setURL(image.src);\n        };\n      }\n    }\n    handleThumbnailLoad(imgThumbnail, setThumbnailImageURL);\n    handleThumbnailLoad(imgFeatured, setFeaturedImageURL);\n    const astraWpEditorCss = document.getElementById('astra-wp-editor-styles-inline-css')?.textContent.replace(/:root/g, '.block-container').replace(/body/g, '.block-container'),\n      astraBlockEditorCss = document.getElementById('astra-block-editor-styles-inline-css')?.textContent.replace(/:root/g, '.block-container').replace(/body/g, '.block-container');\n    let markup = ``;\n    if (stylesheet) {\n      stylesheet = replaceContainerImages(stylesheet, previewImages?.landscape);\n    }\n    markup += astraCustomizer ? `<style type=\"text/css\" id=\"gt-astra-customizer\">${astraCustomizer}</style>` : '';\n    markup += `<style type=\"text/css\" id=\"gt-spectra-common-stylesheet\">${spectra_common_styles}</style>`;\n    markup = stylesheet ? `${markup} <style type=\"text/css\" id=\"gt-common-stylesheet\">${stylesheet}</style>` : markup;\n    if (globalStylesheet) {\n      markup = markup + `<style type=\"text/css\" id=\"gt-global-stylesheet\"> ${globalStylesheet} </style>`;\n    }\n    if (astraWpEditorCss) {\n      markup = markup + `<style type=\"text/css\" id=\"gt-wpeditor-css\" > ${astraWpEditorCss} </style>`;\n    }\n    if (astraBlockEditorCss) {\n      markup = markup + `<style type=\"text/css\" id=\"gt-blockeditor-css\"> ${astraBlockEditorCss} </style>`;\n    }\n    if (thumbnailContainer && content) {\n      let shadow = thumbnailContainer.shadowRoot;\n      if (shadow === null) {\n        shadow = thumbnailContainer.attachShadow({\n          mode: 'open'\n        });\n      }\n      if (shadow === null) {\n        return;\n      }\n      let original_content = content;\n      if (!disableAi) {\n        const dynamic_content = dynamicContent ? dynamicContent[item.category] : [];\n        if (dynamic_content && Object.keys(dynamic_content)?.length > 0) {\n          Object.keys(dynamic_content).forEach(key => {\n            original_content = dynamic_content[key] !== null ? original_content.replace(key, dynamic_content[key]) : original_content;\n          });\n        }\n        original_content = replaceContactDetails(original_content);\n      }\n      shadow.innerHTML = markup + original_content;\n      colorPalette.forEach((color, index) => {\n        shadow?.host.style.setProperty(`--ast-global-color-${index}`, color);\n      });\n      const shadowContent = thumbnailContainer.shadowRoot.querySelectorAll('div')[0];\n      shadowContent?.classList.add('st-block-container');\n      const images = thumbnailContainer.shadowRoot.querySelectorAll('img');\n      if (shadow) {\n        images.forEach(imageItem => {\n          if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.shouldSkipReplacement)(imageItem.src) || disableAi || previewImages.landscape.length === 0 || previewImages.portrait.length === 0) {\n            return;\n          }\n          updateVisibility(imageItem, visibility.hidden);\n        });\n        updateScaling();\n        replaceImages(images, previewImages);\n      }\n    }\n    return () => {\n      isMounted = false;\n    };\n  }, [item, disableAi, dynamicContent]);\n  (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.useEffect)(() => {\n    const resizeObserver = new ResizeObserver(updateScaling);\n    resizeObserver.observe(document.documentElement);\n    return () => {\n      if (!resizeObserver) {\n        return;\n      }\n      resizeObserver.disconnect();\n    };\n  }, []);\n  (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.useEffect)(() => {\n    const astPopup = document.querySelector('#ast-block-templates-modal-wrap');\n    if (!astPopup) {\n      return;\n    }\n    const observer = new MutationObserver(updateScaling);\n    observer.observe(astPopup, {\n      childList: true,\n      attributes: true,\n      subtree: true\n    });\n    return () => {\n      if (!observer) {\n        return;\n      }\n      observer.disconnect();\n    };\n  }, []);\n  (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.useEffect)(() => {\n    const thumbnailContainer = thumbnailContainerRef?.current;\n    if (thumbnailContainer) {\n      const shadow = thumbnailContainer.shadowRoot;\n      colorPalette.forEach((color, index) => {\n        if (shadow === null) {\n          return;\n        }\n        shadow.host.style.setProperty(`--ast-global-color-${index}`, color);\n      });\n    }\n  }, [colorPalette]);\n  function updateScaling() {\n    const thumbnail = thumbnailRef?.current;\n    const thumbnailContainer = thumbnailContainerRef?.current;\n    if (!thumbnail || !thumbnailContainer) {\n      return;\n    }\n    const width = thumbnail.parentNode.offsetWidth;\n    const scale = width / 1200;\n    const scaledHeight = scale * thumbnailContainer.offsetHeight;\n    thumbnail.style.transform = `scale(${scale})`;\n    thumbnail.style.height = `${scaledHeight}px`;\n  }\n  const updateVisibility = (element, value) => {\n    if (!element) {\n      return;\n    }\n    element.style.visibility = value;\n  };\n  return /*#__PURE__*/React.createElement(\"div\", {\n    className: (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_0__.classNames)('w-full h-fit p-5', true === selfState.importing ? 'importing' : '')\n  }, /*#__PURE__*/React.createElement(\"div\", {\n    className: \"cursor-pointer relative border border-solid border-border-primary hover:border-accent-spectra transition duration-150 ease-in-out overflow-hidden group\"\n  }, /*#__PURE__*/React.createElement(\"div\", {\n    className: \"thumbnail left-0 m-0 min-h-[auto] overflow-visible text-left top-0 origin-top-left relative pointer-events-none\",\n    ref: thumbnailRef\n  }, /*#__PURE__*/React.createElement(\"div\", {\n    className: \"absolute w-[1200px] pointer-events-none max-h-[1600px] overflow-hidden\",\n    ref: thumbnailContainerRef\n  }, !content && /*#__PURE__*/React.createElement(\"img\", {\n    srcSet: `${imageFeaturedlURL}, ${imageThumbnailURL}`,\n    src: imageThumbnailURL,\n    alt: \"Preview\"\n  }), /*#__PURE__*/React.createElement(\"div\", {\n    className: \"preview\"\n  }, /*#__PURE__*/React.createElement(\"span\", {\n    className: \"ast-block-templates-icon ast-block-templates-icon-search\"\n  })))), /*#__PURE__*/React.createElement(\"div\", {\n    className: \"absolute inset-0 grid grid-cols-1 grid-rows-1 place-items-end\"\n  }, /*#__PURE__*/React.createElement(\"div\", {\n    className: (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_0__.classNames)('opacity-0 group-hover:opacity-100 w-full flex items-center justify-between px-[20px] py-[14px] backdrop-blur-sm bg-white/[0.85] shadow-action-buttons transition-all duration-150 ease-in-out', true === selfState.importing ? 'opacity-100' : '')\n  }, /*#__PURE__*/React.createElement(_import_block_button_import_block_button_new__WEBPACK_IMPORTED_MODULE_1__[\"default\"], {\n    title: \"Insert\",\n    liveRequest: true,\n    item: item,\n    importing: selfState.importing,\n    onClick: () => {\n      setSelfState({\n        ...selfState,\n        importing: true\n      });\n    },\n    onBlockImport: () => {\n      setSelfState({\n        ...selfState,\n        importing: false\n      });\n    }\n  }), /*#__PURE__*/React.createElement(_favorite_single_block__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n    item: item\n  })))));\n};\n/* harmony default export */ __webpack_exports__[\"default\"] = ((0,_wordpress_compose__WEBPACK_IMPORTED_MODULE_5__[\"default\"])((0,_wordpress_data__WEBPACK_IMPORTED_MODULE_6__[\"default\"])(select => {\n  const {\n    getDisableAi,\n    getDisablePreview\n  } = select('ast-block-templates');\n  return {\n    disableAi: getDisableAi(),\n    disablePreview: getDisablePreview()\n  };\n}))((0,_wordpress_element__WEBPACK_IMPORTED_MODULE_4__.memo)(SingleBlock)));\n\n//# sourceURL=webpack://ast-block-templates/./src/components/reusable/single-block/lazy-single-block-new.js?" );
		/***/ } ),

	/***/ './src/components/reusable/single-block/utils.js':
	/*!*******************************************************!*\
  !*** ./src/components/reusable/single-block/utils.js ***!
  \*******************************************************/
	/***/ ( function( __unused_webpack_module, __webpack_exports__, __webpack_require__ ) {
		eval( "__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   getImageOrientation: function() { return /* binding */ getImageOrientation; },\n/* harmony export */   shouldSkipReplacement: function() { return /* binding */ shouldSkipReplacement; },\n/* harmony export */   withinIframe: function() { return /* binding */ withinIframe; }\n/* harmony export */ });\nconst withinIframe = () => {\n  if (window.location.href !== window.parent.location.href) {\n    return true;\n  }\n  return false;\n};\nconst getImageOrientation = imageUrl => {\n  // eslint-disable-next-line no-undef\n  const img = new Image();\n  img.src = imageUrl;\n  if (img.width > img.height) {\n    return 'landscape';\n  }\n  return 'portrait';\n};\nconst shouldSkipReplacement = imageUrl => {\n  const skipKeywords = ['skip', 'logo', 'fav-icon'];\n  for (const keyword of skipKeywords) {\n    if (imageUrl.includes(keyword)) {\n      return true;\n    }\n  }\n  return false;\n};\n\n//# sourceURL=webpack://ast-block-templates/./src/components/reusable/single-block/utils.js?" );
		/***/ } ),

	/***/ './node_modules/@heroicons/react/24/outline/esm/HeartIcon.js':
	/*!*******************************************************************!*\
  !*** ./node_modules/@heroicons/react/24/outline/esm/HeartIcon.js ***!
  \*******************************************************************/
	/***/ ( function( __unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__ ) {
		eval( '__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");\n\nfunction HeartIcon({\n  title,\n  titleId,\n  ...props\n}, svgRef) {\n  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("svg", Object.assign({\n    xmlns: "http://www.w3.org/2000/svg",\n    fill: "none",\n    viewBox: "0 0 24 24",\n    strokeWidth: 1.5,\n    stroke: "currentColor",\n    "aria-hidden": "true",\n    ref: svgRef,\n    "aria-labelledby": titleId\n  }, props), title ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("title", {\n    id: titleId\n  }, title) : null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("path", {\n    strokeLinecap: "round",\n    strokeLinejoin: "round",\n    d: "M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12z"\n  }));\n}\nconst ForwardRef = react__WEBPACK_IMPORTED_MODULE_0__.forwardRef(HeartIcon);\n/* harmony default export */ __webpack_exports__["default"] = (ForwardRef);\n\n//# sourceURL=webpack://ast-block-templates/./node_modules/@heroicons/react/24/outline/esm/HeartIcon.js?' );
		/***/ } ),

} ] );
